package com.fuxue.controller.server;

import com.fuxue.dto.CommitDTO;
import com.fuxue.dto.GetCommitDTO;
import com.fuxue.result.PageResult;
import com.fuxue.result.Result;
import com.fuxue.service.CommitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/users/server/forum/commit")
@Slf4j
@Api(tags = "评论有关页面")
public class CommitController {
    @Autowired
    private CommitService commitService;
    /*
     评论
      */
    @PostMapping("/CommitForAnswer")
    @ApiOperation("对回答进行评论")
    private Result CommitForAll(@RequestBody CommitDTO commitDTO )
    {
        log.info("论坛评论，参数为：{}",commitDTO);
        commitService.InsertCommit(commitDTO);
        commitDTO.setCreatTime(LocalDateTime.now());
        return Result.success(commitDTO);
    }
    @GetMapping("/Commit")
    @ApiOperation("查询评论")
    private Result<PageResult>getCommit(GetCommitDTO getCommitDTO)
    {
        log.info("论坛评论分页查询，参数为：{}",getCommitDTO);
        PageResult pageResult = commitService.pageQuery(getCommitDTO);

        return Result.success(pageResult);
    }
}
